<template>
  <div style="width: 100%">
    <el-form ref="form" :rules="rules" :model="form" label-width="80px">
      <el-form-item label="分组名称" prop="name">
        <el-input v-model="form.name"></el-input>
      </el-form-item>
      <el-form-item label-width="0px" style="text-align: center">
        <el-button type="primary" @click="onSubmit">{{form.id?'保存修改':'确认添加'}}</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  name: "edit-dept",
  data() {
    return {
      form: {},
      rules: {
        name: [
          {required: true, message: '请输入分组名称', trigger: 'blur'}
        ]
      }
    }
  },methods: {
    onSubmit() {
      this.$refs['form'].validate((valid) => {
        if (valid) {
          this.$emit('submit',this.form)
        } else {
          return false;
        }
      })
    },
    reset() {
      this.form = {}
    },
    loadData(form) {
      this.form = form
    }
  }
}
</script>

<style scoped>

</style>
